/**
 * @Author: SevDaisy十七散人 
 * @Date: 2020-07-10 09:20:55
 */
package zyy.model;

import java.util.Date;

import zyy.util.Bus;

// 视图创建语句
// CREATE VIEW ViewUserOrder as 
// select 
// OrderID, 
// o.UserID UserID,
// oRiderID RiderID,
// r.rName rName,
// o.MID MID,
// m.mName mNname,
// u.uTelnumber uTelphone,
// o.planTime planTime,
// o.oValue oValue,
// o.oRealValue oRealValue,
// o.oStatus oStatus,
// concat(am.addrProvince," ",am.addrCity," ",am.addrBlock," ",am.addrDetail," ",":"," ",am.targetName) mAddr,
// concat(au.addrProvince," ",au.addrCity," ",au.addrBlock," ",au.addrDetail," ",":"," ",au.targetName) uAddr
// from Orders o
// left join Merchant m on o.MID=m.MID
// left join Address am on m.AddressID=am.AddressID
// left join Rider r on o.oRiderID=r.RiderID
// left join Address au on o.uAddressID=au.AddressID
// left join Users u on o.UserID=u.UserID
public class BeanViewOrder {
  public static final String[] tblTitles = { "订单ID", "骑手", "商家", "商家地址", "收货地址", "收件电话", "期望送达时间", "支付价格", "订单状态" };
  private int OrderID; // 订单ID
  private int UserID;
  private int RiderID;
  private String rName;
  private int MID;
  private String mName;
  private String mAddr;
  private String uAddr;
  private String uTelphone;
  private Date planTime;
  private double oValue;
  private double oRealValue;
  private String oStatus; // 新建订单(初始化插入),点品中,已支付,已送达(关闭订单), || 配送中，超时，已送达，取消订单

  public String getCell(int col) {
    switch (col) {
      case 0:
        return this.OrderID + "";
      case 1:
        return this.rName == null ? "" : this.rName;
      case 2:
        return this.mName == null ? "" : this.mName;
      case 3:
        return this.mAddr;
      case 4:
        return this.uAddr;
      case 5:
        return this.uTelphone == null ? "" : this.uTelphone;
      case 6:
        // SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH点mm分ss秒");
        // bug 当未结算时 planTime 为 NULL 需要注意空指针异常
        return planTime != null ? Bus.sdf.format(planTime) : "";
      case 7:
        return String.format("%.2f", this.oRealValue);
      case 8:
        return this.oStatus;
      default:
        return "";
    }
  }

  public int getOrderID() {
    return OrderID;
  }

  public void setOrderID(int orderID) {
    OrderID = orderID;
  }

  public int getUserID() {
    return UserID;
  }

  public void setUserID(int userID) {
    UserID = userID;
  }

  public int getRiderID() {
    return RiderID;
  }

  public void setRiderID(int riderID) {
    RiderID = riderID;
  }

  public String getrName() {
    return rName;
  }

  public void setrName(String rName) {
    this.rName = rName;
  }

  public int getMID() {
    return MID;
  }

  public void setMID(int mID) {
    MID = mID;
  }

  public String getmName() {
    return mName;
  }

  public void setmName(String mName) {
    this.mName = mName;
  }

  public String getmAddr() {
    return mAddr;
  }

  public void setmAddr(String mAddr) {
    this.mAddr = mAddr;
  }

  public String getuAddr() {
    return uAddr;
  }

  public void setuAddr(String uAddr) {
    this.uAddr = uAddr;
  }

  public String getuTelphone() {
    return uTelphone;
  }

  public void setuTelphone(String uTelphone) {
    this.uTelphone = uTelphone;
  }

  public Date getPlanTime() {
    return planTime;
  }

  public void setPlanTime(Date planTime) {
    this.planTime = planTime;
  }

  public double getoValue() {
    return oValue;
  }

  public void setoValue(double oValue) {
    this.oValue = oValue;
  }

  public double getoRealValue() {
    return oRealValue;
  }

  public void setoRealValue(double oRealValue) {
    this.oRealValue = oRealValue;
  }

  public String getoStatus() {
    return oStatus;
  }

  public void setoStatus(String oStatus) {
    this.oStatus = oStatus;
  }

  @Override
  public String toString() {
    return "BeanViewOrder [MID=" + MID + ", OrderID=" + OrderID + ", RiderID=" + RiderID + ", UserID=" + UserID
        + ", mAddr=" + mAddr + ", mName=" + mName + ", oRealValue=" + oRealValue + ", oStatus=" + oStatus + ", oValue="
        + oValue + ", planTime=" + planTime + ", rName=" + rName + ", uAddr=" + uAddr + ", uTelphone=" + uTelphone
        + "]";
  }

}